{include file="pageheader_erp.htm"}

<link href="styles/erp_warehousing.css" rel="stylesheet" type="text/css" />

{insert_scripts files="../js/jquery.1.3.2.js"}
{insert_scripts files="../js/jquery.blockUI.2.23.js"}

{include file="erp_warehousing_search.htm"}

<style type="text/css">
	.current_page_style
	{
		color:red;
		font-weight:bold;
	}
</style>

<script type=text/javascript>
	
	function view_approve_remark(warehousing_id)
	{
		$.blockUI({ 
		  message: $('#approve_remark_'+warehousing_id), css: { 
		  top:  ($(window).height()-300) /2 + 'px', 
		  left: ($(window).width()-500) /2 + 'px'
		  }
		});	
	}
	
	$(document).ready(function(){
		$("img[id^='img_close_approve_remark_']").click(function(){
			$.unblockUI();
		});
		$("img[id^='img_submit_approve_']").click(function(){
			$.unblockUI();
		});	
			
	});
	
</script>


{foreach from=$warehousing_info item=warehousing_info_item}
{if $warehousing_info_item.status eq 3 or $warehousing_info_item.status eq 3}

<div class="approve_remark" id="approve_remark_{$warehousing_info_item.warehousing_id}">
<div class="approve_remark_head">
	<table cellpadding="0" cellspacing="0" border='0'>
		<tr>
			<td>
				<img src="./images/approve_remark.gif" />
			</td>
			<td align="right">
				<span><img style="cursor:pointer;" id="img_close_approve_remark_{$warehousing_info_item.warehousing_id}" src="./images/close_erp.gif" /></span>
			</td>
		</tr>
	</table>
</div>

<div class="approve_remark_box">
<table  cellpadding="5" cellspacing="0" border='0'>
	 <tr>
    	<td width="60">{$lang.erp_approve_remark}</td>	
		<td>
			<textarea rows="8" cols="55" disabled="true" id="textarea_approve_remark_{$warehousing_info_item.warehousing_id}">{$warehousing_info_item.approve_remark}</textarea>
		</td>
	</tr>	
</table>
</div>
<div class="div_submit_approve">
	<img id="img_submit_approve_{$warehousing_info_item.warehousing_id}" src="./images/submit.gif" />
</div>	
</div>

{/if}
{/foreach}


<!-- start warehousing list -->
 <div class="list-div" id="listDiv">
<table  cellpadding="3" cellspacing="1">
  <tr>
    <th  width="5%">{$lang.erp_warehousing_id}</th>
    <th>{$lang.erp_warehousing_sn}</th>	
	<th>{$lang.erp_warehousing_warehouse}</th>
	<th>{$lang.erp_warehousing_admin}</th>		
 	<th>{$lang.erp_warehousing_warehousing_style}</th>	
	<th>{$lang.erp_warehousing_order}</th>	
	<th>{$lang.erp_warehousing_from}</th>
	<th>{$lang.erp_warehousing_date}</th>
	<th>{$lang.erp_warehousing_status}</th>
	<th width="15%">{$lang.erp_operation}</th>
  </tr>
  {foreach from=$warehousing_info key=key item=warehousing_info_item}
 	<tr>
 		<td align="center">{$warehousing_info_item.warehousing_id}</td>
		<td align="center">{$warehousing_info_item.warehousing_sn}</td>
		<td align="center">{$warehousing_info_item.warehouse_info.name}</td>
		<td align="center">{$warehousing_info_item.admin_name}</td>
		<td align="center">{$warehousing_info_item.warehousing_style_info.warehousing_style}</td>
		<td align="center">{$warehousing_info_item.order_info.order_sn}</td>
		<td align="center">{$warehousing_info_item.warehousing_from}</td>
		<td align="center">{$warehousing_info_item.warehousing_date}</td>
		
		<td align="center">
			{if $warehousing_info_item.status eq 1}{$lang.erp_warehousing_status_inputing}{/if}
			{if $warehousing_info_item.status eq 2}{$lang.erp_warehousing_status_approving}{/if}
			{if $warehousing_info_item.status eq 3}<span style="color:blue;">{$lang.erp_warehousing_status_approve_pass}</span>{/if}
			{if $warehousing_info_item.status eq 4}<span style="color:red;">{$lang.erp_warehousing_status_approve_reject}</span>{/if}
		</td>
		<td align="center">
			{if $warehousing_info_item.available_act.view eq 1}
				<a href="erp_warehouse_manage.php?act=view_warehousing&id={$warehousing_info_item.warehousing_id}">{$lang.erp_operation_view}</a>
				{if $warehousing_info_item.status eq 3 or $warehousing_info_item.status eq 4 }
					<a href="javascript:view_approve_remark({$warehousing_info_item.warehousing_id})">{$lang.erp_warehousing_operation_approve_remark}</a>
				{/if}
				{if $warehousing_info_item.status eq 3}
					<a target="_blank" href="erp_warehouse_manage.php?act=print_warehousing&id={$warehousing_info_item.warehousing_id}">{$lang.erp_operation_print}</a>
				{/if}
			{/if}
			
			{if $warehousing_info_item.available_act.edit eq 1}
				<a href="erp_warehouse_manage.php?act=edit_warehousing&id={$warehousing_info_item.warehousing_id}">{$lang.erp_operation_edit}</a>
			{/if}
			{if $warehousing_info_item.available_act.delete eq 1}
				<a href="javascript:delete_warehousing({$warehousing_info_item.warehousing_id})">{$lang.erp_operation_delete}</a>
			{/if}

			{if $warehousing_info_item.available_act.post_to_approve eq 1}
				<a href="javascript:post_warehousing({$warehousing_info_item.warehousing_id})">{$lang.erp_operation_post_to_approve}</a>
			{/if}				
					
			{if $warehousing_info_item.available_act.approve eq 1}
				<a href="erp_warehouse_manage.php?act=approve_warehousing&id={$warehousing_info_item.warehousing_id}">{$lang.erp_operation_approve}</a>
				<a href="javascript:withdrawal_to_edit({$warehousing_info_item.warehousing_id})">{$lang.erp_operation_withdrawal}</a>
			{/if}
		</td>
 	</tr>
  {foreachelse}
  <tr><td class="no-records" colspan="10">{$lang.no_records}</td></tr>
  {/foreach}
  <tr><td colspan="10" align="right">{$page}</td></tr> 
</table>
</div>
<!-- end warehousing list -->

{literal}
<script language="JavaScript">
	
	function add_warehousing()
	{
		function addWarehousingResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				window.document.location='./erp_warehouse_manage.php?act=edit_warehousing&id='+res.warehousing_id;
			}			
		}
		
		Ajax.call('erp_warehousing.php?act=add_warehousing', '', addWarehousingResponse, 'POST', 'JSON');
	}
	
	function withdrawal_to_edit(warehousing_id)
	{
		function withdrawalToEditResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				window.document.location="./erp_warehouse_manage.php?act=warehousing_list";
			}
		}
		if(confirm('{$lang.erp_warehousing_sure_to_withdrawal_to_edit}'))
		{	
			Ajax.call('erp_warehousing.php?act=withdrawal_to_edit', 'warehousing_id=' + warehousing_id, withdrawalToEditResponse, 'POST', 'JSON');
		}			
	}	
	
	
	function post_warehousing(warehousing_id)
	{
		function postWarehousingResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				window.document.location="./erp_warehouse_manage.php?act=warehousing_list";
			}				
		}
		if(confirm('{$lang.erp_warehousing_sure_to_post_warehousing}'))
		{	
			Ajax.call('erp_warehousing.php?act=post_warehousing', 'warehousing_id='+warehousing_id, postWarehousingResponse, 'POST', 'JSON');
		}
	}
	
	function approve_warehousing(warehousing_id)
	{
		function approveWarehousingResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				window.document.location="./erp_warehouse_manage.php?act=warehousing_list";
			}
		}
		
		Ajax.call('erp_warehousing.php?act=approve_pass', 'warehousing_id='+warehousing_id, approveWarehousingResponse, 'POST', 'JSON');
	}	
	
		
	function delete_warehousing(warehousing_id)
	{
		function deleteWarehousingResponse(res)
		{
			if(res.error!=0)
			{
				alert(res.message);
			}
			else{
				window.document.location="erp_warehouse_manage.php?act=warehousing_list";;
			}			
		}
		if(confirm('{$lang.erp_warehousing_sure_to_delete_warehousing}'))
		{	
			Ajax.call('erp_warehousing.php?act=delete_warehousing', 'warehousing_id='+warehousing_id, deleteWarehousingResponse, 'POST', 'JSON');
		}			
	}
	
</script>
{/literal}
{include file="pagefooter.htm"}

